{template header}
{php doAction('tseditor','mini')}
<link rel="stylesheet"  href="{SITE_URL}app/vote/skins/{$skin}/vote.css"  type="text/css" />
<script src="{SITE_URL}app/vote/js/jquery.vote.js"></script>
<script src="{SITE_URL}app/vote/js/vote.js"></script>
<div class="container">

    <ol class="breadcrumb">
        <li><a href="{SITE_URL}">首页</a></li>
        <li><a href="{tsUrl('vote')}">投票</a></li>
        <li class="active">{tsTitle($vote['topic'])}</li>
    </ol>

    <div class="row">
        <script>
            function inputOnclick(thisobj,numMax){
                var num=numMax
                var h=0
                var e=$("[name='optionid[]']");
                for(var i=0 ; i<e.length ; i++){
                    if (e[i].checked==true){
                        h++
                        if  (h>(num)){
                            art.dialog({
                                content : '本投票最多只能选择'+num+'个选项!\n\n如果你确定要投票给此选项，请先去除一个已选择项!。',
                                time : 2000,
                            })
                            thisobj.checked=false;
                        }
                    }
                }
            }

        </script>
        <div class="col-md-8">



            <div class="panel panel-default">
                <div class="panel-heading">{$vote['user']['username']}的投票</div>
                <div class="panel-body">

                    <div class="vote">
                        <div>发起时间：{php echo getTime(strtotime($vote['addtime']),time())}
                            <br />
                            已投票：{$allCount}
                            <br />
                            结束时间：{$vote['endtime']}</div>


                        <ul class="vote-box-list clearfix" id="appVoteBox">
                            <form name="form1" method="post" action="{tsUrl('vote','show',array('ts'=>'do'))}">

                                <input type="hidden" name="voteid" value="{$vote['voteid']}">

                                <center><h1>{$vote['topic']} {if $type==1} （多选） {/if}</h1></center>
                                <div class="pd10" style="color:#999;">{$vote['content']}</div>
                                {loop $arrOption $key  $item}

                                <li class="vl-item" id="voteItem0">
                                    <div class="vote-item-wrap">
                                        <h4>{tsTitle($item['name'])}：</h4>
                                        <p class="litem"><em class=vleft></em><span></span><em class=vright></em>
                                        </p><span class=vnum>{$item['count_vote']} ({php echo 100*$item['precent']}%)</span>
                                        {if $type==1}
                                        <input type="checkbox" onclick="javascript:inputOnclick(this,{$optionCount});" value="{$item['optionid']}" name="optionid[]"  >
                                        {else}
                                        <input type="radio" name="optionid" value="{$item['optionid']}">
                                        {/if}
                                    </div>
                                </li>
                                {/loop}

                                {if $time < $endtime}
                                <div class="tac">
                                    <input class="btn btn-success" type="submit" value="投票" ></div>
                                {else}
                                <div class="tac"><b class="btn btn-default">投票结束</b></div>
                                {/if}
                            </form>
                        </ul>

                    </div>
                </div>
            </div>



            <script>
                Vote.ListShow.init({
                    id: 'appVoteBox',
                    percent: [ {$pp},],
                    width: 183 - 2
                });
                Vote.ListShow.go();
            </script>


            <div class="panel panel-default">
                <div class="panel-heading">谁在投票</div>
                <div class="panel-body">

                    <div class="commlist">
                <ul>
                    {loop $voteRecord $key $item}
                    <li><a href="">{$item['user']['username']}</a> {php echo date('m-d H:i',strtotime($item['addtime']))} 投票给 '{$item['select']['name']}'</li>
                    {/loop}
                </ul>

                    </div>


            </div>
            </div>


            <div class="panel panel-default">
                <div class="panel-heading">用户评论({$Comments})</div>
                <div class="panel-body">

                    <div  class="comment">
                    <ul>
                        {loop $arrVoteComment $key $item}
                        <li>
                            <div class="user-face">
                                <a href=""><img class="img-circle" title="{$item[user][username]}" src="{$item['user']['face']}" width="48" /></a>
                            </div>
                            <div class="reply-doc">
                                <h4>{$item[addtime]}
                                    <a href="">{$item[user][username]}</a>
                                    <i>{php echo ($key+1)}#</i>
                                </h4>
                                <p>
                                    {$item['comment']}
                                </p>

                                {if $TS_USER['isadmin']==1 || $strAlbum['userid']==$userid}

                                <a  style="float:right;" href="{tsUrl('vote','comment',array('ts'=>'delete','commentid'=>$item['commentid'],'voteid'=>$vote['voteid']))}"  onClick="return confirm('确定要删除这个评论?')">删除</a>


                                {/if}
                            </div>
                        </li>
                        {/loop}
                    </ul>

                    </div>


                    <div class="page">{$pageUrl}</div>

                    {if $TS_USER}
                    <form method="POST" action="{tsUrl('vote','comment',array('ts'=>'do'))}" >
                        <p><textarea style="width:100%;" id="tseditor" name="comment"></textarea></p>
                        <p><input type="hidden" name="voteid" value="{$vote['voteid']}" />
                            <input class="btn btn-success" type="submit" value="提交评论" /></p>
                    </form>
                    {/if}
                </div>
            </div>

        </div>



        <div class="col-md-4">

            <div class="panel panel-default">
                <div class="panel-body">
                    <a class="btn btn-success" href="{tsUrl('vote','add')}">发起投票</a>
                </div>
            </div>


            <div class="panel panel-default">
                <div class="panel-heading">热门投票</div>
                <div class="panel-body">
                    <div class="commlist">
                        <ul>
                            {loop $arrHotVote $key $item}
                            <li class="pd010"><a href="{tsUrl('vote','show',array('id'=>$item['voteid']))}">{php echo cututf8($item['topic'],0,20)}</a></li>
                            {/loop}
                        </ul>
                    </div>
                </div>
            </div>

            <!--广告位-->
            {php doAction('gobad','300')}

        </div>
    </div>

</div>
{template footer}